package com.example.as_sum.permission;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;

/**
 * Created by ran on 2016/7/29.
 */
public class PermissionsUtil {
    /**
     * 检查这个权限是否被授权
     * @param mContext
     * @param permission 检查的权限
     * @return true表示没有被授权
     */
    public static boolean checkPermission(Context mContext,String permission) {
        return ContextCompat.checkSelfPermission(mContext, permission) ==
                PackageManager.PERMISSION_DENIED;
    }
    /**
     * 检查这一组权限是否被授权
     * @param context
     * @param permissions
     * @return
     */
    public static boolean checkGroupPermission(Context context,String... permissions) {
        for (String permission : permissions) {
            if (checkPermission(context,permission)) {
                return true;
            }
        }
        return false;
    }

}
